// 可以完全按照 JavaScript 标准语法编写代码

// const hello = (name: string) => {
//   console.log(`hello,${name}`)
// }

// hello('Typescript')


// const a: string = 'footbar'

// const b: symbol = Symbol()

// Array

// (function () {
//   const a = 123
// })()

export {}
const foo: object = function () {}

const obj: { foo: number, bar: string } = { foo: 123, bar: 'string' }

const arr1: Array<number> = [1,2,3]
const arr2: number[] = [1,2,3]

function sum (...args: number[]) {
  return args.reduce((prev, current) => prev + current, 0)
}

sum(1,2,3)


const tuple: [number, string] = [18, '22']

const [age, name] = tuple

Object.entries(
  {
    foo: 3,
    bar: '2'
  }
)

enum PostStatus {
  Draft = 0,
  Unpublished,
  Pulished
}


function func1 (a: number, b: number): string {
  return 'func1'
}

func1(1,2)

const func2 = function (a: number, b:number): string {
  return 'func2'
}


function stringify (value: any) {
  return JSON.stringify(value)
}

let b = 100

interface Post {
  title: string
  content: string
  subtitle?: string
  readonly sumary: string
}

function printPost (post: Post) {
  console.log(post.title)
  console.log(post.content)
}

printPost(
  {
    title: '2',
    content: '22',
    sumary: '000'
  }
)

class Person {
  public name: string //= 'init name'
  private age: number
  protected gender: boolean
  constructor (name: string, age: number) {
    this.name = name
    this.age = age
    this.gender = true
  }
  sayHi (msg: string): void {
    console.log(`I am ${this.name}, ${msg}`)
  }
}

class Student extends Person {
  private constructor (name: string, age: number) {
    super(name, age)
    console.log(this.gender)
  }
  static create (name: string, age: number) {
    return new Student(name, age)
  }
}

const tom = new Person('tom', 18)
const jack = Student.create('tom', 18)

// console.log(tom.age)
// console.log(tom.gender)

interface Eat {
  eat (food: string): void
}
interface Run {
  run (distance: number): void
}
class Human implements Eat, Run {
  eat (food: string): void {
    console.log(`优雅的进餐：${food}`)
  }
  run (distance: number) {
    console.log(`直立行走：${distance}`)
  }
}

class Animal implements Eat, Run {
  eat (food: string): void {
    console.log(`呼噜呼噜的吃：${food}`)
  }
  run (distance: number) {
    console.log(`爬行：${distance}`)
  }
}

// 抽象类
abstract class Animal2 {
  eat (food: string): void {
    console.log(`呼噜呼噜的吃：${food}`)
  }
  abstract run (distance: number) :void
}

function creatNumberArray (length: number, value: number): number[] {
  const arr = Array<number>(length).fill(value)
  return arr
}


function creatArray<T> (length: number, value: T): T[] {
  const arr = Array<T>(length).fill(value)
  return arr
}

// const res =  creatNumberArray(3, 100)
// const res =  creatArray<string>(3, '100')


import { camelCase } from 'lodash'

// declare function camelCase(input: string): string

const res = camelCase('hello types')

function main () {
  
}